package com.example.authoritymanageaopproject;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
    private Button mBossBtn;
    private Button mAdminBtn;
    private Button mStuff1Btn;
    private Button mStuff2Btn;

    private Person mBoss;
    private Person mAdmin;
    private Person mStuffA;
    private Person mStuffB;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_activity);
        initView();
        intiData();
    }

    private void intiData() {
        mBoss = new Boss("Boss");
        mAdmin = new Admin("Admin");
        mStuffA = new Stuff("StuffA");
        mStuffB = new Stuff("StuffB");
    }

    private void initView() {
        mBossBtn = (Button) findViewById(R.id.main_boss_btn);
        mBossBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mBoss.openDB();
            }
        });

        mAdminBtn = (Button) findViewById(R.id.main_admin_btn);
        mAdminBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mAdmin.openDB();
            }
        });

        mStuff1Btn = (Button) findViewById(R.id.main_stuff_1_btn);
        mStuff1Btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mStuffA.openDB();
            }
        });

        mStuff2Btn = (Button) findViewById(R.id.main_stuff_2_btn);
        mStuff2Btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mStuffB.openDB();
            }
        });
    }

}
